import http from './http'

//获取下拉列表
function dropList() {
    return http.post('/course-api//weChat/applet/subject/list', { enable: 1 })
}

//评论接口
function commentList(url) {
    return http.get(`/course-api/pc/comment/commentList/course/${url}?pageNum=1&pageSize=10`, { enable: 1 })
}
//课程描述目录接口
function descriptionList(url) {
    return http.get(`/course-api//pc/course/detail/${url}`)
}

//普通登录接口
function ordinaryLogin(username,password) {
    let urlParams = new URLSearchParams()
    urlParams.append('username',username)
    urlParams.append('password',password)
    urlParams.append("rememberMe",true)
    return http.post('/course-api/pcUser/login',urlParams)
}

//手机号登录验证码
function phoneCode(phone) {
    return http.get(`/course-api//pcUser/login/send/code/${phone}`)

}
//手机号登录
function phoneLogin(mobile,code) {
    let urlParams = new URLSearchParams()
    urlParams.append('mobile',mobile)
    urlParams.append('code',code)
    urlParams.append("rememberMe",true)
    return http.post('/course-api/pcUser/login/mobile',urlParams)
}

//注册手机验证码
function addSure(addPhone) {
    return http.get(`/course-api/pcUser/register/send/code/${addPhone}`)
}
//注册账号
function getNum(addSure,addPhone,getAddName,getAddPwd,getAddId) {
    // addSure:'',
    //     //    注册
    //     addPhone:'',
    //     getAddName:'',
    //     getAddSurePwd:'',
    //     getAddPwd:'',
    //     getAddId:''
    let form = new URLSearchParams()
    // 编码类型为其他时使用
    // let form = new FormData()
    form.append("addSure", addSure)
    form.append("addPhone", addPhone)
    form.append("getAddName", getAddName)
    form.append("getAddPwd", getAddPwd)
    form.append("getAddId", getAddId)
    return http.post('/course-api/pcUser/register',form)
}

//退出登录
function logout() {
    return http.get('/course-api/pcUser/logout')
}

//获取个人信息
function getUserInfo() {
    return http.get("/course-api/pcUser/login-user/info")
}



// 修改头像
function changeAvatar(file) {
    let form = new FormData()
    form.append("file",file)
    return http.post("/course-api/pcUser/updata/userAvatar",form)

}

//导出
export {
    dropList,
    commentList,
    descriptionList,
    ordinaryLogin,
    logout,
    getUserInfo,
    changeAvatar,
    phoneCode,
    phoneLogin,
    addSure,
    getNum
}